<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Unicode::Collate - Unicode Collation Algorithm - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Unicode::Collate">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Unicode::Collate.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Unicode::Collate">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Unicode::Collate">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Unicode::Collate">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Unicode::Collate">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Unicode::Collate">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Unicode::Collate">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Unicode::Collate">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Unicode::Collate">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Unicode::Collate">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Unicode::Collate">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Unicode::Collate">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Unicode::Collate">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Unicode::Collate">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Unicode::Collate">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Unicode::Collate">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Unicode::Collate">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Unicode::Collate">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Unicode::Collate">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Unicode::Collate">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Unicode::Collate">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Unicode::Collate">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Unicode::Collate">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Unicode::Collate">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Unicode::Collate">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Unicode::Collate">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Unicode::Collate">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Unicode::Collate">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Unicode::Collate">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Unicode::Collate">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Unicode::Collate">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Unicode::Collate">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Unicode::Collate">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Unicode::Collate">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Unicode::Collate">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Unicode::Collate">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Unicode::Collate">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Unicode::Collate">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Unicode::Collate">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Unicode::Collate">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Unicode::Collate">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Unicode::Collate">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Unicode::Collate">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Unicode::Collate">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Unicode::Collate">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Unicode::Collate">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Unicode::Collate">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Unicode::Collate">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Unicode::Collate">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Unicode::Collate">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Unicode::Collate">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Unicode::Collate">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Unicode::Collate">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Unicode::Collate">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Unicode::Collate">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Unicode::Collate">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Unicode::Collate">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Unicode::Collate">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Unicode::Collate">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Unicode::Collate">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Unicode::Collate">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Unicode::Collate">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Unicode::Collate">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Unicode::Collate">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Unicode::Collate">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Unicode::Collate">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Unicode::Collate">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Unicode::Collate">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Unicode::Collate">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Unicode::Collate">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Unicode::Collate">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Unicode::Collate">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Unicode::Collate">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Unicode::Collate">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Unicode::Collate">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Unicode::Collate">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Unicode::Collate">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Unicode::Collate">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Unicode::Collate">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Unicode::Collate">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Unicode::Collate">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Unicode::Collate.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Unicode::Collate">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Unicode::Collate">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Unicode::Collate">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Unicode::Collate">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Unicode::Collate">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Unicode::Collate">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Unicode::Collate">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Unicode::Collate">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Unicode::Collate">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Unicode::Collate">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Unicode::Collate">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Unicode::Collate">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Unicode::Collate">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Unicode::Collate">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Unicode::Collate">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Unicode::Collate">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Unicode::Collate">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Unicode::Collate">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Unicode::Collate">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Unicode::Collate">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Unicode::Collate">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Unicode::Collate">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Unicode::Collate">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Unicode::Collate">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Unicode::Collate">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Unicode::Collate">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Unicode::Collate">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Unicode::Collate">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Unicode::Collate">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Unicode::Collate">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Unicode::Collate">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Unicode::Collate">5.35.1</a>
          <a class="dropdown-item active" href="./Unicode::Collate.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Unicode::Collate.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Unicode::Collate.html">Unicode::Collate</a>
          <div id="more">
            (<a href="./Unicode::Collate.txt">source</a>,
            <a href="https://metacpan.org/pod/Unicode::Collate">CPAN</a>)
          </div>
            <div id="moduleversion">version 1.29</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#DESCRIPTION">DESCRIPTION</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#Constructor-and-Tailoring">Constructor and Tailoring</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#Methods-for-Collation">Methods for Collation</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#Methods-for-Searching">Methods for Searching</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#Other-Methods">Other Methods</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#EXPORT">EXPORT</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#INSTALL">INSTALL</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#CAVEATS">CAVEATS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#AUTHOR,-COPYRIGHT-AND-LICENSE">AUTHOR, COPYRIGHT AND LICENSE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Unicode::Collate.html#SEE-ALSO">SEE ALSO</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Unicode::Collate.html#NAME">#</a>NAME</h1>

<p>Unicode::Collate - Unicode Collation Algorithm</p>

<h1 id="SYNOPSIS"><a class="permalink" href="./Unicode::Collate.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<pre><code>use Unicode::Collate;

#construct
$Collator = Unicode::Collate-&gt;new(%tailoring);

#sort
@sorted = $Collator-&gt;sort(@not_sorted);

#compare
$result = $Collator-&gt;cmp($a, $b); # returns 1, 0, or -1.</code></pre>

<p><b>Note:</b> Strings in <code>@not_sorted</code>, <code>$a</code> and <code>$b</code> are interpreted according to Perl&#39;s Unicode support. See <a href="perlunicode.html">perlunicode</a>, <a href="perluniintro.html">perluniintro</a>, <a href="perlunitut.html">perlunitut</a>, <a href="perlunifaq.html">perlunifaq</a>, <a href="utf8.html">utf8</a>. Otherwise you can use <code>preprocess</code> or should decode them before.</p>

<h1 id="DESCRIPTION"><a class="permalink" href="./Unicode::Collate.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>This module is an implementation of Unicode Technical Standard #10 (a.k.a. UTS #10) - Unicode Collation Algorithm (a.k.a. UCA).</p>

<h2 id="Constructor-and-Tailoring"><a class="permalink" href="./Unicode::Collate.html#Constructor-and-Tailoring">#</a><a id="Constructor"></a>Constructor and Tailoring</h2>

<p>The <code>new</code> method returns a collator object. If new() is called with no parameters, the collator should do the default collation.</p>

<pre><code>$Collator = Unicode::Collate-&gt;new(
   UCA_Version =&gt; $UCA_Version,
   alternate =&gt; $alternate, # alias for &#39;variable&#39;
   backwards =&gt; $levelNumber, # or \@levelNumbers
   entry =&gt; $element,
   hangul_terminator =&gt; $term_primary_weight,
   highestFFFF =&gt; $bool,
   identical =&gt; $bool,
   ignoreName =&gt; qr/$ignoreName/,
   ignoreChar =&gt; qr/$ignoreChar/,
   ignore_level2 =&gt; $bool,
   katakana_before_hiragana =&gt; $bool,
   level =&gt; $collationLevel,
   long_contraction =&gt; $bool,
   minimalFFFE =&gt; $bool,
   normalization  =&gt; $normalization_form,
   overrideCJK =&gt; \&amp;overrideCJK,
   overrideHangul =&gt; \&amp;overrideHangul,
   preprocess =&gt; \&amp;preprocess,
   rearrange =&gt; \@charList,
   rewrite =&gt; \&amp;rewrite,
   suppress =&gt; \@charList,
   table =&gt; $filename,
   undefName =&gt; qr/$undefName/,
   undefChar =&gt; qr/$undefChar/,
   upper_before_lower =&gt; $bool,
   variable =&gt; $variable,
);</code></pre>

<dl>

<dt id="UCA_Version"><a class="permalink" href="./Unicode::Collate.html#UCA_Version">#</a>UCA_Version</dt>
<dd>

<p>If the revision (previously &quot;tracking version&quot;) number of UCA is given, behavior of that revision is emulated on collating. If omitted, the return value of <code>UCA_Version()</code> is used.</p>

<p>The following revisions are supported. The default is 43.</p>

<pre><code>  UCA       Unicode Standard         DUCET (@version)
-------------------------------------------------------
   8              3.1                3.0.1 (3.0.1d9)
   9     3.1 with Corrigendum 3      3.1.1
  11             4.0.0
  14             4.1.0
  16             5.0.0
  18             5.1.0
  20             5.2.0
  22             6.0.0
  24             6.1.0
  26             6.2.0
  28             6.3.0
  30             7.0.0
  32             8.0.0
  34             9.0.0
  36            10.0.0
  38            11.0.0
  40            12.0.0
  41            12.1.0
  43            13.0.0</code></pre>

<p>* See below for <code>long_contraction</code> with <code>UCA_Version</code> 22 and 24.</p>

<p>* Noncharacters (e.g. U+FFFF) are not ignored, and can be overridden since <code>UCA_Version</code> 22.</p>

<p>* Out-of-range codepoints (greater than U+10FFFF) are not ignored, and can be overridden since <code>UCA_Version</code> 22.</p>

<p>* Fully ignorable characters were ignored, and would not interrupt contractions with <code>UCA_Version</code> 9 and 11.</p>

<p>* Treatment of ignorables after variables and some behaviors were changed at <code>UCA_Version</code> 9.</p>

<p>* Characters regarded as CJK unified ideographs (cf. <code>overrideCJK</code>) depend on <code>UCA_Version</code>.</p>

<p>* Many hangul jamo are assigned at <code>UCA_Version</code> 20, that will affect <code>hangul_terminator</code>.</p>

</dd>
<dt id="alternate"><a class="permalink" href="./Unicode::Collate.html#alternate">#</a>alternate</dt>
<dd>

<p>-- see 3.2.2 Alternate Weighting, version 8 of UTS #10</p>

<p>For backward compatibility, <code>alternate</code> (old name) can be used as an alias for <code>variable</code>.</p>

</dd>
<dt id="backwards"><a class="permalink" href="./Unicode::Collate.html#backwards">#</a>backwards</dt>
<dd>

<p>-- see 3.4 Backward Accents, UTS #10.</p>

<pre><code>backwards =&gt; $levelNumber or \@levelNumbers</code></pre>

<p>Weights in reverse order; ex. level 2 (diacritic ordering) in French. If omitted (or <code>$levelNumber</code> is <code>undef</code> or <code>\@levelNumbers</code> is <code>[]</code>), forwards at all the levels.</p>

</dd>
<dt id="entry"><a class="permalink" href="./Unicode::Collate.html#entry">#</a>entry</dt>
<dd>

<p>-- see 5 Tailoring; 9.1 Allkeys File Format, UTS #10.</p>

<p>If the same character (or a sequence of characters) exists in the collation element table through <code>table</code>, mapping to collation elements is overridden. If it does not exist, the mapping is defined additionally.</p>

<pre><code class="plaintext">entry =&gt; &lt;&lt;&#39;ENTRY&#39;, # for DUCET v4.0.0 (allkeys-4.0.0.txt)
0063 0068 ; [.0E6A.0020.0002.0063] # ch
0043 0068 ; [.0E6A.0020.0007.0043] # Ch
0043 0048 ; [.0E6A.0020.0008.0043] # CH
006C 006C ; [.0F4C.0020.0002.006C] # ll
004C 006C ; [.0F4C.0020.0007.004C] # Ll
004C 004C ; [.0F4C.0020.0008.004C] # LL
00F1      ; [.0F7B.0020.0002.00F1] # n-tilde
006E 0303 ; [.0F7B.0020.0002.00F1] # n-tilde
00D1      ; [.0F7B.0020.0008.00D1] # N-tilde
004E 0303 ; [.0F7B.0020.0008.00D1] # N-tilde
ENTRY

entry =&gt; &lt;&lt;&#39;ENTRY&#39;, # for DUCET v4.0.0 (allkeys-4.0.0.txt)
00E6 ; [.0E33.0020.0002.00E6][.0E8B.0020.0002.00E6] # ae ligature as &lt;a&gt;&lt;e&gt;
00C6 ; [.0E33.0020.0008.00C6][.0E8B.0020.0008.00C6] # AE ligature as &lt;A&gt;&lt;E&gt;
ENTRY</code></pre>

<p><b>NOTE:</b> The code point in the UCA file format (before <code>&#39;;&#39;</code>) <b>must</b> be a Unicode code point (defined as hexadecimal), but not a native code point. So <code>0063</code> must always denote <code>U+0063</code>, but not a character of <code>&quot;\x63&quot;</code>.</p>

<p>Weighting may vary depending on collation element table. So ensure the weights defined in <code>entry</code> will be consistent with those in the collation element table loaded via <code>table</code>.</p>

<p>In DUCET v4.0.0, primary weight of <code>C</code> is <code>0E60</code> and that of <code>D</code> is <code>0E6D</code>. So setting primary weight of <code>CH</code> to <code>0E6A</code> (as a value between <code>0E60</code> and <code>0E6D</code>) makes ordering as <code>C &lt; CH &lt; D</code>. Exactly speaking DUCET already has some characters between <code>C</code> and <code>D</code>: <code>small capital C</code> (<code>U+1D04</code>) with primary weight <code>0E64</code>, <code>c-hook/C-hook</code> (<code>U+0188/U+0187</code>) with <code>0E65</code>, and <code>c-curl</code> (<code>U+0255</code>) with <code>0E69</code>. Then primary weight <code>0E6A</code> for <code>CH</code> makes <code>CH</code> ordered between <code>c-curl</code> and <code>D</code>.</p>

</dd>
<dt id="hangul_terminator"><a class="permalink" href="./Unicode::Collate.html#hangul_terminator">#</a>hangul_terminator</dt>
<dd>

<p>-- see 7.1.4 Trailing Weights, UTS #10.</p>

<p>If a true value is given (non-zero but should be positive), it will be added as a terminator primary weight to the end of every standard Hangul syllable. Secondary and any higher weights for terminator are set to zero. If the value is false or <code>hangul_terminator</code> key does not exist, insertion of terminator weights will not be performed.</p>

<p>Boundaries of Hangul syllables are determined according to conjoining Jamo behavior in <i>the Unicode Standard</i> and <i>HangulSyllableType.txt</i>.</p>

<p><b>Implementation Note:</b> (1) For expansion mapping (Unicode character mapped to a sequence of collation elements), a terminator will not be added between collation elements, even if Hangul syllable boundary exists there. Addition of terminator is restricted to the next position to the last collation element.</p>

<p>(2) Non-conjoining Hangul letters (Compatibility Jamo, halfwidth Jamo, and enclosed letters) are not automatically terminated with a terminator primary weight. These characters may need terminator included in a collation element table beforehand.</p>

</dd>
<dt id="highestFFFF"><a class="permalink" href="./Unicode::Collate.html#highestFFFF">#</a>highestFFFF</dt>
<dd>

<p>-- see 2.4 Tailored noncharacter weights, UTS #35 (LDML) Part 5: Collation.</p>

<p>If the parameter is made true, <code>U+FFFF</code> has a highest primary weight. When a boolean of <code>$coll-&gt;ge($str, &quot;abc&quot;)</code> and <code>$coll-&gt;le($str, &quot;abc\x{FFFF}&quot;)</code> is true, it is expected that <code>$str</code> begins with <code>&quot;abc&quot;</code>, or another primary equivalent. <code>$str</code> may be <code>&quot;abcd&quot;</code>, <code>&quot;abc012&quot;</code>, but should not include <code>U+FFFF</code> such as <code>&quot;abc\x{FFFF}xyz&quot;</code>.</p>

<p><code>$coll-&gt;le($str, &quot;abc\x{FFFF}&quot;)</code> works like <code>$coll-&gt;lt($str, &quot;abd&quot;)</code> almost, but the latter has a problem that you should know which letter is next to <code>c</code>. For a certain language where <code>ch</code> as the next letter, <code>&quot;abch&quot;</code> is greater than <code>&quot;abc\x{FFFF}&quot;</code>, but less than <code>&quot;abd&quot;</code>.</p>

<p>Note: This is equivalent to <code>(entry =&gt; &#39;FFFF ; [.FFFE.0020.0005.FFFF]&#39;)</code>. Any other character than <code>U+FFFF</code> can be tailored by <code>entry</code>.</p>

</dd>
<dt id="identical"><a class="permalink" href="./Unicode::Collate.html#identical">#</a>identical</dt>
<dd>

<p>-- see A.3 Deterministic Comparison, UTS #10.</p>

<p>By default, strings whose weights are equal should be equal, even though their code points are not equal. Completely ignorable characters are ignored.</p>

<p>If the parameter is made true, a final, tie-breaking level is used. If no difference of weights is found after the comparison through all the level specified by <code>level</code>, the comparison with code points will be performed. For the tie-breaking comparison, the sort key has code points of the original string appended. Completely ignorable characters are not ignored.</p>

<p>If <code>preprocess</code> and/or <code>normalization</code> is applied, the code points of the string after them (in NFD by default) are used.</p>

</dd>
<dt id="ignoreChar"><a class="permalink" href="./Unicode::Collate.html#ignoreChar">#</a>ignoreChar</dt>
<dd>

</dd>
<dt id="ignoreName"><a class="permalink" href="./Unicode::Collate.html#ignoreName">#</a>ignoreName</dt>
<dd>

<p>-- see 3.6 Variable Weighting, UTS #10.</p>

<p>Makes the entry in the table completely ignorable; i.e. as if the weights were zero at all level.</p>

<p>Through <code>ignoreChar</code>, any character matching <code>qr/$ignoreChar/</code> will be ignored. Through <code>ignoreName</code>, any character whose name (given in the <code>table</code> file as a comment) matches <code>qr/$ignoreName/</code> will be ignored.</p>

<p>E.g. when &#39;a&#39; and &#39;e&#39; are ignorable, &#39;element&#39; is equal to &#39;lament&#39; (or &#39;lmnt&#39;).</p>

</dd>
<dt id="ignore_level2"><a class="permalink" href="./Unicode::Collate.html#ignore_level2">#</a>ignore_level2</dt>
<dd>

<p>-- see 5.1 Parametric Tailoring, UTS #10.</p>

<p>By default, case-sensitive comparison (that is level 3 difference) won&#39;t ignore accents (that is level 2 difference).</p>

<p>If the parameter is made true, accents (and other primary ignorable characters) are ignored, even though cases are taken into account.</p>

<p><b>NOTE</b>: <code>level</code> should be 3 or greater.</p>

</dd>
<dt id="katakana_before_hiragana"><a class="permalink" href="./Unicode::Collate.html#katakana_before_hiragana">#</a>katakana_before_hiragana</dt>
<dd>

<p>-- see 7.2 Tertiary Weight Table, UTS #10.</p>

<p>By default, hiragana is before katakana. If the parameter is made true, this is reversed.</p>

<p><b>NOTE</b>: This parameter simplemindedly assumes that any hiragana/katakana distinctions must occur in level 3, and their weights at level 3 must be same as those mentioned in 7.3.1, UTS #10. If you define your collation elements which violate this requirement, this parameter does not work validly.</p>

</dd>
<dt id="level"><a class="permalink" href="./Unicode::Collate.html#level">#</a>level</dt>
<dd>

<p>-- see 4.3 Form Sort Key, UTS #10.</p>

<p>Set the maximum level. Any higher levels than the specified one are ignored.</p>

<pre><code class="plaintext">Level 1: alphabetic ordering
Level 2: diacritic ordering
Level 3: case ordering
Level 4: tie-breaking (e.g. in the case when variable is &#39;shifted&#39;)

ex.level =&gt; 2,</code></pre>

<p>If omitted, the maximum is the 4th.</p>

<p><b>NOTE:</b> The DUCET includes weights over 0xFFFF at the 4th level. But this module only uses weights within 0xFFFF. When <code>variable</code> is &#39;blanked&#39; or &#39;non-ignorable&#39; (other than &#39;shifted&#39; and &#39;shift-trimmed&#39;), the level 4 may be unreliable.</p>

<p>See also <code>identical</code>.</p>

</dd>
<dt id="long_contraction"><a class="permalink" href="./Unicode::Collate.html#long_contraction">#</a>long_contraction</dt>
<dd>

<p>-- see 3.8.2 Well-Formedness of the DUCET, 4.2 Produce Array, UTS #10.</p>

<p>If the parameter is made true, for a contraction with three or more characters (here nicknamed &quot;long contraction&quot;), initial substrings will be handled. For example, a contraction ABC, where A is a starter, and B and C are non-starters (character with non-zero combining character class), will be detected even if there is not AB as a contraction.</p>

<p><b>Default:</b> Usually false. If <code>UCA_Version</code> is 22 or 24, and the value of <code>long_contraction</code> is not specified in <code>new()</code>, a true value is set implicitly. This is a workaround to pass Conformance Tests for Unicode 6.0.0 and 6.1.0.</p>

<p><code>change()</code> handles <code>long_contraction</code> explicitly only. If <code>long_contraction</code> is not specified in <code>change()</code>, even though <code>UCA_Version</code> is changed, <code>long_contraction</code> will not be changed.</p>

<p><b>Limitation:</b> Scanning non-starters is one-way (no back tracking). If AB is found but not ABC is not found, other long contraction where the first character is A and the second is not B may not be found.</p>

<p>Under <code>(normalization =&gt; undef)</code>, detection step of discontiguous contractions will be skipped.</p>

<p><b>Note:</b> The following contractions in DUCET are not considered in steps S2.1.1 to S2.1.3, where they are discontiguous.</p>

<pre><code class="plaintext">0FB2 0F71 0F80 (TIBETAN VOWEL SIGN VOCALIC RR)
0FB3 0F71 0F80 (TIBETAN VOWEL SIGN VOCALIC LL)</code></pre>

<p>For example <code>TIBETAN VOWEL SIGN VOCALIC RR</code> with <code>COMBINING TILDE OVERLAY</code> (<code>U+0344</code>) is <code>0FB2 0344 0F71 0F80</code> in NFD. In this case <code>0FB2 0F80</code> (<code>TIBETAN VOWEL SIGN VOCALIC R</code>) is detected, instead of <code>0FB2 0F71 0F80</code>. Inserted <code>0344</code> makes <code>0FB2 0F71 0F80</code> discontiguous and lack of contraction <code>0FB2 0F71</code> prohibits <code>0FB2 0F71 0F80</code> from being detected.</p>

</dd>
<dt id="minimalFFFE"><a class="permalink" href="./Unicode::Collate.html#minimalFFFE">#</a>minimalFFFE</dt>
<dd>

<p>-- see 1.1.1 U+FFFE, UTS #35 (LDML) Part 5: Collation.</p>

<p>If the parameter is made true, <code>U+FFFE</code> has a minimal primary weight. The comparison between <code>&quot;$a1\x{FFFE}$a2&quot;</code> and <code>&quot;$b1\x{FFFE}$b2&quot;</code> first compares <code>$a1</code> and <code>$b1</code> at level 1, and then <code>$a2</code> and <code>$b2</code> at level 1, as followed.</p>

<pre><code class="plaintext">&quot;ab\x{FFFE}a&quot;
&quot;Ab\x{FFFE}a&quot;
&quot;ab\x{FFFE}c&quot;
&quot;Ab\x{FFFE}c&quot;
&quot;ab\x{FFFE}xyz&quot;
&quot;abc\x{FFFE}def&quot;
&quot;abc\x{FFFE}xYz&quot;
&quot;aBc\x{FFFE}xyz&quot;
&quot;abcX\x{FFFE}def&quot;
&quot;abcx\x{FFFE}xyz&quot;
&quot;b\x{FFFE}aaa&quot;
&quot;bbb\x{FFFE}a&quot;</code></pre>

<p>Note: This is equivalent to <code>(entry =&gt; &#39;FFFE ; [.0001.0020.0005.FFFE]&#39;)</code>. Any other character than <code>U+FFFE</code> can be tailored by <code>entry</code>.</p>

</dd>
<dt id="normalization"><a class="permalink" href="./Unicode::Collate.html#normalization">#</a>normalization</dt>
<dd>

<p>-- see 4.1 Normalize, UTS #10.</p>

<p>If specified, strings are normalized before preparation of sort keys (the normalization is executed after preprocess).</p>

<p>A form name <code>Unicode::Normalize::normalize()</code> accepts will be applied as <code>$normalization_form</code>. Acceptable names include <code>&#39;NFD&#39;</code>, <code>&#39;NFC&#39;</code>, <code>&#39;NFKD&#39;</code>, and <code>&#39;NFKC&#39;</code>. See <code>Unicode::Normalize::normalize()</code> for detail. If omitted, <code>&#39;NFD&#39;</code> is used.</p>

<p><code>normalization</code> is performed after <code>preprocess</code> (if defined).</p>

<p>Furthermore, special values, <code>undef</code> and <code>&quot;prenormalized&quot;</code>, can be used, though they are not concerned with <code>Unicode::Normalize::normalize()</code>.</p>

<p>If <code>undef</code> (not a string <code>&quot;undef&quot;</code>) is passed explicitly as the value for this key, any normalization is not carried out (this may make tailoring easier if any normalization is not desired). Under <code>(normalization =&gt; undef)</code>, only contiguous contractions are resolved; e.g. even if <code>A-ring</code> (and <code>A-ring-cedilla</code>) is ordered after <code>Z</code>, <code>A-cedilla-ring</code> would be primary equal to <code>A</code>. In this point, <code>(normalization =&gt; undef, preprocess =&gt; sub { NFD(shift) })</code> <b>is not</b> equivalent to <code>(normalization =&gt; &#39;NFD&#39;)</code>.</p>

<p>In the case of <code>(normalization =&gt; &quot;prenormalized&quot;)</code>, any normalization is not performed, but discontiguous contractions with combining characters are performed. Therefore <code>(normalization =&gt; &#39;prenormalized&#39;, preprocess =&gt; sub { NFD(shift) })</code> <b>is</b> equivalent to <code>(normalization =&gt; &#39;NFD&#39;)</code>. If source strings are finely prenormalized, <code>(normalization =&gt; &#39;prenormalized&#39;)</code> may save time for normalization.</p>

<p>Except <code>(normalization =&gt; undef)</code>, <b>Unicode::Normalize</b> is required (see also <b>CAVEAT</b>).</p>

</dd>
<dt id="overrideCJK"><a class="permalink" href="./Unicode::Collate.html#overrideCJK">#</a>overrideCJK</dt>
<dd>

<p>-- see 7.1 Derived Collation Elements, UTS #10.</p>

<p>By default, CJK unified ideographs are ordered in Unicode codepoint order, but those in the CJK Unified Ideographs block are less than those in the CJK Unified Ideographs Extension A etc.</p>

<pre><code class="plaintext">In the CJK Unified Ideographs block:
U+4E00..U+9FA5 if UCA_Version is 8, 9 or 11.
U+4E00..U+9FBB if UCA_Version is 14 or 16.
U+4E00..U+9FC3 if UCA_Version is 18.
U+4E00..U+9FCB if UCA_Version is 20 or 22.
U+4E00..U+9FCC if UCA_Version is 24 to 30.
U+4E00..U+9FD5 if UCA_Version is 32 or 34.
U+4E00..U+9FEA if UCA_Version is 36.
U+4E00..U+9FEF if UCA_Version is 38, 40 or 41.
U+4E00..U+9FFC if UCA_Version is 43.

In the CJK Unified Ideographs Extension blocks:
Ext.A (U+3400..U+4DB5)   if UCA_Version is  8 to 41.
Ext.A (U+3400..U+4DBF)   if UCA_Version is 43.
Ext.B (U+20000..U+2A6D6) if UCA_Version is  8 to 41.
Ext.B (U+20000..U+2A6DD) if UCA_Version is 43.
Ext.C (U+2A700..U+2B734) if UCA_Version is 20 or later.
Ext.D (U+2B740..U+2B81D) if UCA_Version is 22 or later.
Ext.E (U+2B820..U+2CEA1) if UCA_Version is 32 or later.
Ext.F (U+2CEB0..U+2EBE0) if UCA_Version is 36 or later.
Ext.G (U+30000..U+3134A) if UCA_Version is 43.</code></pre>

<p>Through <code>overrideCJK</code>, ordering of CJK unified ideographs (including extensions) can be overridden.</p>

<p>ex. CJK unified ideographs in the JIS code point order.</p>

<pre><code>overrideCJK =&gt; sub {
    my $u = shift;             # get a Unicode codepoint
    my $b = pack(&#39;n&#39;, $u);     # to UTF-16BE
    my $s = your_unicode_to_sjis_converter($b); # convert
    my $n = unpack(&#39;n&#39;, $s);   # convert sjis to short
    [ $n, 0x20, 0x2, $u ];     # return the collation element
},</code></pre>

<p>The return value may be an arrayref of 1st to 4th weights as shown above. The return value may be an integer as the primary weight as shown below. If <code>undef</code> is returned, the default derived collation element will be used.</p>

<pre><code>overrideCJK =&gt; sub {
    my $u = shift;             # get a Unicode codepoint
    my $b = pack(&#39;n&#39;, $u);     # to UTF-16BE
    my $s = your_unicode_to_sjis_converter($b); # convert
    my $n = unpack(&#39;n&#39;, $s);   # convert sjis to short
    return $n;                 # return the primary weight
},</code></pre>

<p>The return value may be a list containing zero or more of an arrayref, an integer, or <code>undef</code>.</p>

<p>ex. ignores all CJK unified ideographs.</p>

<pre><code>overrideCJK =&gt; sub {()}, # CODEREF returning empty list

 # where -&gt;eq(&quot;Pe\x{4E00}rl&quot;, &quot;Perl&quot;) is true
 # as U+4E00 is a CJK unified ideograph and to be ignorable.</code></pre>

<p>If a false value (including <code>undef</code>) is passed, <code>overrideCJK</code> has no effect. <code>$Collator-&gt;change(overrideCJK =&gt; 0)</code> resets the old one.</p>

<p>But assignment of weight for CJK unified ideographs in <code>table</code> or <code>entry</code> is still valid. If <code>undef</code> is passed explicitly as the value for this key, weights for CJK unified ideographs are treated as undefined. However when <code>UCA_Version</code> &gt; 8, <code>(overrideCJK =&gt; undef)</code> has no special meaning.</p>

<p><b>Note:</b> In addition to them, 12 CJK compatibility ideographs (<code>U+FA0E</code>, <code>U+FA0F</code>, <code>U+FA11</code>, <code>U+FA13</code>, <code>U+FA14</code>, <code>U+FA1F</code>, <code>U+FA21</code>, <code>U+FA23</code>, <code>U+FA24</code>, <code>U+FA27</code>, <code>U+FA28</code>, <code>U+FA29</code>) are also treated as CJK unified ideographs. But they can&#39;t be overridden via <code>overrideCJK</code> when you use DUCET, as the table includes weights for them. <code>table</code> or <code>entry</code> has priority over <code>overrideCJK</code>.</p>

</dd>
<dt id="overrideHangul"><a class="permalink" href="./Unicode::Collate.html#overrideHangul">#</a>overrideHangul</dt>
<dd>

<p>-- see 7.1 Derived Collation Elements, UTS #10.</p>

<p>By default, Hangul syllables are decomposed into Hangul Jamo, even if <code>(normalization =&gt; undef)</code>. But the mapping of Hangul syllables may be overridden.</p>

<p>This parameter works like <code>overrideCJK</code>, so see there for examples.</p>

<p>If you want to override the mapping of Hangul syllables, NFD and NFKD are not appropriate, since NFD and NFKD will decompose Hangul syllables before overriding. FCD may decompose Hangul syllables as the case may be.</p>

<p>If a false value (but not <code>undef</code>) is passed, <code>overrideHangul</code> has no effect. <code>$Collator-&gt;change(overrideHangul =&gt; 0)</code> resets the old one.</p>

<p>If <code>undef</code> is passed explicitly as the value for this key, weight for Hangul syllables is treated as undefined without decomposition into Hangul Jamo. But definition of weight for Hangul syllables in <code>table</code> or <code>entry</code> is still valid.</p>

</dd>
<dt id="overrideOut"><a class="permalink" href="./Unicode::Collate.html#overrideOut">#</a>overrideOut</dt>
<dd>

<p>-- see 7.1.1 Handling Ill-Formed Code Unit Sequences, UTS #10.</p>

<p>Perl seems to allow out-of-range values (greater than 0x10FFFF). By default, out-of-range values are replaced with <code>U+FFFD</code> (REPLACEMENT CHARACTER) when <code>UCA_Version</code> &gt;= 22, or ignored when <code>UCA_Version</code> &lt;= 20.</p>

<p>When <code>UCA_Version</code> &gt;= 22, the weights of out-of-range values can be overridden. Though <code>table</code> or <code>entry</code> are available for them, out-of-range values are too many.</p>

<p><code>overrideOut</code> can perform it algorithmically. This parameter works like <code>overrideCJK</code>, so see there for examples.</p>

<p>ex. ignores all out-of-range values.</p>

<pre><code class="plaintext">overrideOut =&gt; sub {()}, # CODEREF returning empty list</code></pre>

<p>If a false value (including <code>undef</code>) is passed, <code>overrideOut</code> has no effect. <code>$Collator-&gt;change(overrideOut =&gt; 0)</code> resets the old one.</p>

<p><b>NOTE ABOUT U+FFFD:</b></p>

<p>UCA recommends that out-of-range values should not be ignored for security reasons. Say, <code>&quot;pe\x{110000}rl&quot;</code> should not be equal to <code>&quot;perl&quot;</code>. However, <code>U+FFFD</code> is wrongly mapped to a variable collation element in DUCET for Unicode 6.0.0 to 6.2.0, that means out-of-range values will be ignored when <code>variable</code> isn&#39;t <code>Non-ignorable</code>.</p>

<p>The mapping of <code>U+FFFD</code> is corrected in Unicode 6.3.0. see <a href="http://www.unicode.org/reports/tr10/tr10-28.html#Trailing_Weights">http://www.unicode.org/reports/tr10/tr10-28.html#Trailing_Weights</a> (7.1.4 Trailing Weights). Such a correction is reproduced by this.</p>

<pre><code class="plaintext">overrideOut =&gt; sub { 0xFFFD }, # CODEREF returning a very large integer</code></pre>

<p>This workaround is unnecessary since Unicode 6.3.0.</p>

</dd>
<dt id="preprocess"><a class="permalink" href="./Unicode::Collate.html#preprocess">#</a>preprocess</dt>
<dd>

<p>-- see 5.4 Preprocessing, UTS #10.</p>

<p>If specified, the coderef is used to preprocess each string before the formation of sort keys.</p>

<p>ex. dropping English articles, such as &quot;a&quot; or &quot;the&quot;. Then, &quot;the pen&quot; is before &quot;a pencil&quot;.</p>

<pre><code>preprocess =&gt; sub {
      my $str = shift;
      $str =~ s/\b(?:an?|the)\s+//gi;
      return $str;
   },</code></pre>

<p><code>preprocess</code> is performed before <code>normalization</code> (if defined).</p>

<p>ex. decoding strings in a legacy encoding such as shift-jis:</p>

<pre><code>$sjis_collator = Unicode::Collate-&gt;new(
    preprocess =&gt; \&amp;your_shiftjis_to_unicode_decoder,
);
@result = $sjis_collator-&gt;sort(@shiftjis_strings);</code></pre>

<p><b>Note:</b> Strings returned from the coderef will be interpreted according to Perl&#39;s Unicode support. See <a href="perlunicode.html">perlunicode</a>, <a href="perluniintro.html">perluniintro</a>, <a href="perlunitut.html">perlunitut</a>, <a href="perlunifaq.html">perlunifaq</a>, <a href="utf8.html">utf8</a>.</p>

</dd>
<dt id="rearrange"><a class="permalink" href="./Unicode::Collate.html#rearrange">#</a>rearrange</dt>
<dd>

<p>-- see 3.5 Rearrangement, UTS #10.</p>

<p>Characters that are not coded in logical order and to be rearranged. If <code>UCA_Version</code> is equal to or less than 11, default is:</p>

<pre><code class="plaintext">rearrange =&gt; [ 0x0E40..0x0E44, 0x0EC0..0x0EC4 ],</code></pre>

<p>If you want to disallow any rearrangement, pass <code>undef</code> or <code>[]</code> (a reference to empty list) as the value for this key.</p>

<p>If <code>UCA_Version</code> is equal to or greater than 14, default is <code>[]</code> (i.e. no rearrangement).</p>

<p><b>According to the version 9 of UCA, this parameter shall not be used; but it is not warned at present.</b></p>

</dd>
<dt id="rewrite"><a class="permalink" href="./Unicode::Collate.html#rewrite">#</a>rewrite</dt>
<dd>

<p>If specified, the coderef is used to rewrite lines in <code>table</code> or <code>entry</code>. The coderef will get each line, and then should return a rewritten line according to the UCA file format. If the coderef returns an empty line, the line will be skipped.</p>

<p>e.g. any primary ignorable characters into tertiary ignorable:</p>

<pre><code>rewrite =&gt; sub {
    my $line = shift;
    $line =~ s/\[\.0000\..{4}\..{4}\./[.0000.0000.0000./g;
    return $line;
},</code></pre>

<p>This example shows rewriting weights. <code>rewrite</code> is allowed to affect code points, weights, and the name.</p>

<p><b>NOTE</b>: <code>table</code> is available to use another table file; preparing a modified table once would be more efficient than rewriting lines on reading an unmodified table every time.</p>

</dd>
<dt id="suppress"><a class="permalink" href="./Unicode::Collate.html#suppress">#</a>suppress</dt>
<dd>

<p>-- see 3.12 Special-Purpose Commands, UTS #35 (LDML) Part 5: Collation.</p>

<p>Contractions beginning with the specified characters are suppressed, even if those contractions are defined in <code>table</code>.</p>

<p>An example for Russian and some languages using the Cyrillic script:</p>

<pre><code class="plaintext">suppress =&gt; [0x0400..0x0417, 0x041A..0x0437, 0x043A..0x045F],</code></pre>

<p>where 0x0400 stands for <code>U+0400</code>, CYRILLIC CAPITAL LETTER IE WITH GRAVE.</p>

<p><b>NOTE</b>: Contractions via <code>entry</code> will not be suppressed.</p>

</dd>
<dt id="table"><a class="permalink" href="./Unicode::Collate.html#table">#</a>table</dt>
<dd>

<p>-- see 3.8 Default Unicode Collation Element Table, UTS #10.</p>

<p>You can use another collation element table if desired.</p>

<p>The table file should locate in the <i>Unicode/Collate</i> directory on <code>@INC</code>. Say, if the filename is <i>Foo.txt</i>, the table file is searched as <i>Unicode/Collate/Foo.txt</i> in <code>@INC</code>.</p>

<p>By default, <i>allkeys.txt</i> (as the filename of DUCET) is used. If you will prepare your own table file, any name other than <i>allkeys.txt</i> may be better to avoid namespace conflict.</p>

<p><b>NOTE</b>: When XSUB is used, the DUCET is compiled on building this module, and it may save time at the run time. Explicit saying <code>(table =&gt; &#39;allkeys.txt&#39;)</code>, or using another table, or using <code>ignoreChar</code>, <code>ignoreName</code>, <code>undefChar</code>, <code>undefName</code> or <code>rewrite</code> will prevent this module from using the compiled DUCET.</p>

<p>If <code>undef</code> is passed explicitly as the value for this key, no file is read (but you can define collation elements via <code>entry</code>).</p>

<p>A typical way to define a collation element table without any file of table:</p>

<pre><code>$onlyABC = Unicode::Collate-&gt;new(
    table =&gt; undef,
    entry =&gt; &lt;&lt; &#39;ENTRIES&#39;,
0061 ; [.0101.0020.0002.0061] # LATIN SMALL LETTER A
0041 ; [.0101.0020.0008.0041] # LATIN CAPITAL LETTER A
0062 ; [.0102.0020.0002.0062] # LATIN SMALL LETTER B
0042 ; [.0102.0020.0008.0042] # LATIN CAPITAL LETTER B
0063 ; [.0103.0020.0002.0063] # LATIN SMALL LETTER C
0043 ; [.0103.0020.0008.0043] # LATIN CAPITAL LETTER C
ENTRIES
 );</code></pre>

<p>If <code>ignoreName</code> or <code>undefName</code> is used, character names should be specified as a comment (following <code>#</code>) on each line.</p>

</dd>
<dt id="undefChar"><a class="permalink" href="./Unicode::Collate.html#undefChar">#</a>undefChar</dt>
<dd>

</dd>
<dt id="undefName"><a class="permalink" href="./Unicode::Collate.html#undefName">#</a>undefName</dt>
<dd>

<p>-- see 6.3.3 Reducing the Repertoire, UTS #10.</p>

<p>Undefines the collation element as if it were unassigned in the <code>table</code>. This reduces the size of the table. If an unassigned character appears in the string to be collated, the sort key is made from its codepoint as a single-character collation element, as it is greater than any other assigned collation elements (in the codepoint order among the unassigned characters). But, it&#39;d be better to ignore characters unfamiliar to you and maybe never used.</p>

<p>Through <code>undefChar</code>, any character matching <code>qr/$undefChar/</code> will be undefined. Through <code>undefName</code>, any character whose name (given in the <code>table</code> file as a comment) matches <code>qr/$undefName/</code> will be undefined.</p>

<p>ex. Collation weights for beyond-BMP characters are not stored in object:</p>

<pre><code class="plaintext">undefChar =&gt; qr/[^\0-\x{fffd}]/,</code></pre>

</dd>
<dt id="upper_before_lower"><a class="permalink" href="./Unicode::Collate.html#upper_before_lower">#</a>upper_before_lower</dt>
<dd>

<p>-- see 6.6 Case Comparisons, UTS #10.</p>

<p>By default, lowercase is before uppercase. If the parameter is made true, this is reversed.</p>

<p><b>NOTE</b>: This parameter simplemindedly assumes that any lowercase/uppercase distinctions must occur in level 3, and their weights at level 3 must be same as those mentioned in 7.3.1, UTS #10. If you define your collation elements which differs from this requirement, this parameter doesn&#39;t work validly.</p>

</dd>
<dt id="variable"><a class="permalink" href="./Unicode::Collate.html#variable">#</a>variable</dt>
<dd>

<p>-- see 3.6 Variable Weighting, UTS #10.</p>

<p>This key allows for variable weighting of variable collation elements, which are marked with an ASTERISK in the table (NOTE: Many punctuation marks and symbols are variable in <i>allkeys.txt</i>).</p>

<pre><code class="plaintext">variable =&gt; &#39;blanked&#39;, &#39;non-ignorable&#39;, &#39;shifted&#39;, or &#39;shift-trimmed&#39;.</code></pre>

<p>These names are case-insensitive. By default (if specification is omitted), &#39;shifted&#39; is adopted.</p>

<pre><code>&#39;Blanked&#39;        Variable elements are made ignorable at levels 1 through 3;
                 considered at the 4th level.

&#39;Non-Ignorable&#39;  Variable elements are not reset to ignorable.

&#39;Shifted&#39;        Variable elements are made ignorable at levels 1 through 3
                 their level 4 weight is replaced by the old level 1 weight.
                 Level 4 weight for Non-Variable elements is 0xFFFF.

&#39;Shift-Trimmed&#39;  Same as &#39;shifted&#39;, but all FFFF&#39;s at the 4th level
                 are trimmed.</code></pre>

</dd>
</dl>

<h2 id="Methods-for-Collation"><a class="permalink" href="./Unicode::Collate.html#Methods-for-Collation">#</a><a id="Methods"></a>Methods for Collation</h2>

<dl>

<dt id="@sorted-=-$Collator-&gt;sort(@not_sorted)"><a class="permalink" href="./Unicode::Collate.html#@sorted-=-$Collator-%3Esort(@not_sorted)">#</a><a id="sorted-Collator-sort-not_sorted"></a><code>@sorted = $Collator-&gt;sort(@not_sorted)</code></dt>
<dd>

<p>Sorts a list of strings.</p>

</dd>
<dt id="$result-=-$Collator-&gt;cmp($a,-$b)"><a class="permalink" href="./Unicode::Collate.html#$result-=-$Collator-%3Ecmp($a,-$b)">#</a><a id="result-Collator-cmp-a-b"></a><code>$result = $Collator-&gt;cmp($a, $b)</code></dt>
<dd>

<p>Returns 1 (when <code>$a</code> is greater than <code>$b</code>) or 0 (when <code>$a</code> is equal to <code>$b</code>) or -1 (when <code>$a</code> is less than <code>$b</code>).</p>

</dd>
<dt id="$result-=-$Collator-&gt;eq($a,-$b)"><a class="permalink" href="./Unicode::Collate.html#$result-=-$Collator-%3Eeq($a,-$b)">#</a><a id="result-Collator-eq-a-b"></a><code>$result = $Collator-&gt;eq($a, $b)</code></dt>
<dd>

</dd>
<dt id="$result-=-$Collator-&gt;ne($a,-$b)"><a class="permalink" href="./Unicode::Collate.html#$result-=-$Collator-%3Ene($a,-$b)">#</a><a id="result-Collator-ne-a-b"></a><code>$result = $Collator-&gt;ne($a, $b)</code></dt>
<dd>

</dd>
<dt id="$result-=-$Collator-&gt;lt($a,-$b)"><a class="permalink" href="./Unicode::Collate.html#$result-=-$Collator-%3Elt($a,-$b)">#</a><a id="result-Collator-lt-a-b"></a><code>$result = $Collator-&gt;lt($a, $b)</code></dt>
<dd>

</dd>
<dt id="$result-=-$Collator-&gt;le($a,-$b)"><a class="permalink" href="./Unicode::Collate.html#$result-=-$Collator-%3Ele($a,-$b)">#</a><a id="result-Collator-le-a-b"></a><code>$result = $Collator-&gt;le($a, $b)</code></dt>
<dd>

</dd>
<dt id="$result-=-$Collator-&gt;gt($a,-$b)"><a class="permalink" href="./Unicode::Collate.html#$result-=-$Collator-%3Egt($a,-$b)">#</a><a id="result-Collator-gt-a-b"></a><code>$result = $Collator-&gt;gt($a, $b)</code></dt>
<dd>

</dd>
<dt id="$result-=-$Collator-&gt;ge($a,-$b)"><a class="permalink" href="./Unicode::Collate.html#$result-=-$Collator-%3Ege($a,-$b)">#</a><a id="result-Collator-ge-a-b"></a><code>$result = $Collator-&gt;ge($a, $b)</code></dt>
<dd>

<p>They works like the same name operators as theirs.</p>

<pre><code>eq : whether $a is equal to $b.
ne : whether $a is not equal to $b.
lt : whether $a is less than $b.
le : whether $a is less than $b or equal to $b.
gt : whether $a is greater than $b.
ge : whether $a is greater than $b or equal to $b.</code></pre>

</dd>
<dt id="$sortKey-=-$Collator-&gt;getSortKey($string)"><a class="permalink" href="./Unicode::Collate.html#$sortKey-=-$Collator-%3EgetSortKey($string)">#</a><a id="sortKey-Collator-getSortKey-string"></a><code>$sortKey = $Collator-&gt;getSortKey($string)</code></dt>
<dd>

<p>-- see 4.3 Form Sort Key, UTS #10.</p>

<p>Returns a sort key.</p>

<p>You compare the sort keys using a binary comparison and get the result of the comparison of the strings using UCA.</p>

<pre><code>$Collator-&gt;getSortKey($a) cmp $Collator-&gt;getSortKey($b)

   is equivalent to

$Collator-&gt;cmp($a, $b)</code></pre>

</dd>
<dt id="$sortKeyForm-=-$Collator-&gt;viewSortKey($string)"><a class="permalink" href="./Unicode::Collate.html#$sortKeyForm-=-$Collator-%3EviewSortKey($string)">#</a><a id="sortKeyForm-Collator-viewSortKey-string"></a><code>$sortKeyForm = $Collator-&gt;viewSortKey($string)</code></dt>
<dd>

<p>Converts a sorting key into its representation form. If <code>UCA_Version</code> is 8, the output is slightly different.</p>

<pre><code>use Unicode::Collate;
my $c = Unicode::Collate-&gt;new();
print $c-&gt;viewSortKey(&quot;Perl&quot;),&quot;\n&quot;;

# output:
# [0B67 0A65 0B7F 0B03 | 0020 0020 0020 0020 | 0008 0002 0002 0002 | FFFF FFFF FFFF FFFF]
#  Level 1               Level 2               Level 3               Level 4</code></pre>

</dd>
</dl>

<h2 id="Methods-for-Searching"><a class="permalink" href="./Unicode::Collate.html#Methods-for-Searching">#</a><a id="Methods1"></a>Methods for Searching</h2>

<p>The <code>match</code>, <code>gmatch</code>, <code>subst</code>, <code>gsubst</code> methods work like <code>m//</code>, <code>m//g</code>, <code>s///</code>, <code>s///g</code>, respectively, but they are not aware of any pattern, but only a literal substring.</p>

<p><b>DISCLAIMER:</b> If <code>preprocess</code> or <code>normalization</code> parameter is true for <code>$Collator</code>, calling these methods (<code>index</code>, <code>match</code>, <code>gmatch</code>, <code>subst</code>, <code>gsubst</code>) is croaked, as the position and the length might differ from those on the specified string.</p>

<p><code>rearrange</code> and <code>hangul_terminator</code> parameters are neglected. <code>katakana_before_hiragana</code> and <code>upper_before_lower</code> don&#39;t affect matching and searching, as it doesn&#39;t matter whether greater or less.</p>

<dl>

<dt id="$position-=-$Collator-&gt;index($string,-$substring[,-$position])"><a class="permalink" href="./Unicode::Collate.html#$position-=-$Collator-%3Eindex($string,-$substring%5B,-$position%5D)">#</a><a id="position-Collator-index-string-substring-position"></a><code>$position = $Collator-&gt;index($string, $substring[, $position])</code></dt>
<dd>

</dd>
<dt id="($position,-$length)-=-$Collator-&gt;index($string,-$substring[,-$position])"><a class="permalink" href="./Unicode::Collate.html#($position,-$length)-=-$Collator-%3Eindex($string,-$substring%5B,-$position%5D)">#</a><a id="position-length-Collator-index-string-substring-position"></a><code>($position, $length) = $Collator-&gt;index($string, $substring[, $position])</code></dt>
<dd>

<p>If <code>$substring</code> matches a part of <code>$string</code>, returns the position of the first occurrence of the matching part in scalar context; in list context, returns a two-element list of the position and the length of the matching part.</p>

<p>If <code>$substring</code> does not match any part of <code>$string</code>, returns <code>-1</code> in scalar context and an empty list in list context.</p>

<p>e.g. when the content of <code>$str</code> is <code>&quot;Ich mu</code>ß<code> studieren Perl.&quot;</code>, you say the following where <code>$sub</code> is <code>&quot;M</code>ü<code>SS&quot;</code>,</p>

<pre><code>my $Collator = Unicode::Collate-&gt;new( normalization =&gt; undef, level =&gt; 1 );
                                   # (normalization =&gt; undef) is REQUIRED.
my $match;
if (my($pos,$len) = $Collator-&gt;index($str, $sub)) {
    $match = substr($str, $pos, $len);
}</code></pre>

<p>and get <code>&quot;mu</code>ß<code>&quot;</code> in <code>$match</code>, since <code>&quot;mu</code>ß<code>&quot;</code> is primary equal to <code>&quot;M</code>ü<code>SS&quot;</code>.</p>

</dd>
<dt id="$match_ref-=-$Collator-&gt;match($string,-$substring)"><a class="permalink" href="./Unicode::Collate.html#$match_ref-=-$Collator-%3Ematch($string,-$substring)">#</a><a id="match_ref-Collator-match-string-substring"></a><code>$match_ref = $Collator-&gt;match($string, $substring)</code></dt>
<dd>

</dd>
<dt id="($match)-=-$Collator-&gt;match($string,-$substring)"><a class="permalink" href="./Unicode::Collate.html#($match)-=-$Collator-%3Ematch($string,-$substring)">#</a><a id="match-Collator-match-string-substring"></a><code>($match) = $Collator-&gt;match($string, $substring)</code></dt>
<dd>

<p>If <code>$substring</code> matches a part of <code>$string</code>, in scalar context, returns <b>a reference to</b> the first occurrence of the matching part (<code>$match_ref</code> is always true if matches, since every reference is <b>true</b>); in list context, returns the first occurrence of the matching part.</p>

<p>If <code>$substring</code> does not match any part of <code>$string</code>, returns <code>undef</code> in scalar context and an empty list in list context.</p>

<p>e.g.</p>

<pre><code>    if ($match_ref = $Collator-&gt;match($str, $sub)) { # scalar context
	print &quot;matches [$$match_ref].\n&quot;;
    } else {
	print &quot;doesn&#39;t match.\n&quot;;
    }

     or

    if (($match) = $Collator-&gt;match($str, $sub)) { # list context
	print &quot;matches [$match].\n&quot;;
    } else {
	print &quot;doesn&#39;t match.\n&quot;;
    }</code></pre>

</dd>
<dt id="@match-=-$Collator-&gt;gmatch($string,-$substring)"><a class="permalink" href="./Unicode::Collate.html#@match-=-$Collator-%3Egmatch($string,-$substring)">#</a><a id="match-Collator-gmatch-string-substring"></a><code>@match = $Collator-&gt;gmatch($string, $substring)</code></dt>
<dd>

<p>If <code>$substring</code> matches a part of <code>$string</code>, returns all the matching parts (or matching count in scalar context).</p>

<p>If <code>$substring</code> does not match any part of <code>$string</code>, returns an empty list.</p>

</dd>
<dt id="$count-=-$Collator-&gt;subst($string,-$substring,-$replacement)"><a class="permalink" href="./Unicode::Collate.html#$count-=-$Collator-%3Esubst($string,-$substring,-$replacement)">#</a><a id="count-Collator-subst-string-substring-replacement"></a><code>$count = $Collator-&gt;subst($string, $substring, $replacement)</code></dt>
<dd>

<p>If <code>$substring</code> matches a part of <code>$string</code>, the first occurrence of the matching part is replaced by <code>$replacement</code> (<code>$string</code> is modified) and <code>$count</code> (always equals to <code>1</code>) is returned.</p>

<p><code>$replacement</code> can be a <code>CODEREF</code>, taking the matching part as an argument, and returning a string to replace the matching part (a bit similar to <code>s/(..)/$coderef-&gt;($1)/e</code>).</p>

</dd>
<dt id="$count-=-$Collator-&gt;gsubst($string,-$substring,-$replacement)"><a class="permalink" href="./Unicode::Collate.html#$count-=-$Collator-%3Egsubst($string,-$substring,-$replacement)">#</a><a id="count-Collator-gsubst-string-substring-replacement"></a><code>$count = $Collator-&gt;gsubst($string, $substring, $replacement)</code></dt>
<dd>

<p>If <code>$substring</code> matches a part of <code>$string</code>, all the occurrences of the matching part are replaced by <code>$replacement</code> (<code>$string</code> is modified) and <code>$count</code> is returned.</p>

<p><code>$replacement</code> can be a <code>CODEREF</code>, taking the matching part as an argument, and returning a string to replace the matching part (a bit similar to <code>s/(..)/$coderef-&gt;($1)/eg</code>).</p>

<p>e.g.</p>

<pre><code>my $Collator = Unicode::Collate-&gt;new( normalization =&gt; undef, level =&gt; 1 );
                                   # (normalization =&gt; undef) is REQUIRED.
my $str = &quot;Camel donkey zebra came\x{301}l CAMEL horse cam\0e\0l...&quot;;
$Collator-&gt;gsubst($str, &quot;camel&quot;, sub { &quot;&lt;b&gt;$_[0]&lt;/b&gt;&quot; });

# now $str is &quot;&lt;b&gt;Camel&lt;/b&gt; donkey zebra &lt;b&gt;came\x{301}l&lt;/b&gt; &lt;b&gt;CAMEL&lt;/b&gt; horse &lt;b&gt;cam\0e\0l&lt;/b&gt;...&quot;;
# i.e., all the camels are made bold-faced.

 Examples: levels and ignore_level2 - what does camel match?
---------------------------------------------------------------------------
 level  ignore_level2  |  camel  Camel  came\x{301}l  c-a-m-e-l  cam\0e\0l
-----------------------|---------------------------------------------------
   1        false      |   yes    yes      yes          yes        yes
   2        false      |   yes    yes      no           yes        yes
   3        false      |   yes    no       no           yes        yes
   4        false      |   yes    no       no           no         yes
-----------------------|---------------------------------------------------
   1        true       |   yes    yes      yes          yes        yes
   2        true       |   yes    yes      yes          yes        yes
   3        true       |   yes    no       yes          yes        yes
   4        true       |   yes    no       yes          no         yes
---------------------------------------------------------------------------
 note: if variable =&gt; non-ignorable, camel doesn&#39;t match c-a-m-e-l
       at any level.</code></pre>

</dd>
</dl>

<h2 id="Other-Methods"><a class="permalink" href="./Unicode::Collate.html#Other-Methods">#</a><a id="Other"></a>Other Methods</h2>

<dl>

<dt id="%old_tailoring-=-$Collator-&gt;change(%new_tailoring)"><a class="permalink" href="./Unicode::Collate.html#%25old_tailoring-=-$Collator-%3Echange(%25new_tailoring)">#</a><a id="old_tailoring-Collator-change-new_tailoring"></a><code>%old_tailoring = $Collator-&gt;change(%new_tailoring)</code></dt>
<dd>

</dd>
<dt id="$modified_collator-=-$Collator-&gt;change(%new_tailoring)"><a class="permalink" href="./Unicode::Collate.html#$modified_collator-=-$Collator-%3Echange(%25new_tailoring)">#</a><a id="modified_collator-Collator-change-new_tailoring"></a><code>$modified_collator = $Collator-&gt;change(%new_tailoring)</code></dt>
<dd>

<p>Changes the value of specified keys and returns the changed part.</p>

<pre><code>$Collator = Unicode::Collate-&gt;new(level =&gt; 4);

$Collator-&gt;eq(&quot;perl&quot;, &quot;PERL&quot;); # false

%old = $Collator-&gt;change(level =&gt; 2); # returns (level =&gt; 4).

$Collator-&gt;eq(&quot;perl&quot;, &quot;PERL&quot;); # true

$Collator-&gt;change(%old); # returns (level =&gt; 2).

$Collator-&gt;eq(&quot;perl&quot;, &quot;PERL&quot;); # false</code></pre>

<p>Not all <code>(key,value)</code>s are allowed to be changed. See also <code>@Unicode::Collate::ChangeOK</code> and <code>@Unicode::Collate::ChangeNG</code>.</p>

<p>In the scalar context, returns the modified collator (but it is <b>not</b> a clone from the original).</p>

<pre><code>$Collator-&gt;change(level =&gt; 2)-&gt;eq(&quot;perl&quot;, &quot;PERL&quot;); # true

$Collator-&gt;eq(&quot;perl&quot;, &quot;PERL&quot;); # true; now max level is 2nd.

$Collator-&gt;change(level =&gt; 4)-&gt;eq(&quot;perl&quot;, &quot;PERL&quot;); # false</code></pre>

</dd>
<dt id="$version-=-$Collator-&gt;version()"><a class="permalink" href="./Unicode::Collate.html#$version-=-$Collator-%3Eversion()">#</a><a id="version-Collator-version"></a><code>$version = $Collator-&gt;version()</code></dt>
<dd>

<p>Returns the version number (a string) of the Unicode Standard which the <code>table</code> file used by the collator object is based on. If the table does not include a version line (starting with <code>@version</code>), returns <code>&quot;unknown&quot;</code>.</p>

</dd>
<dt id="UCA_Version()"><a class="permalink" href="./Unicode::Collate.html#UCA_Version()">#</a><a id="UCA_Version1"></a><code>UCA_Version()</code></dt>
<dd>

<p>Returns the revision number of UTS #10 this module consults, that should correspond with the DUCET incorporated.</p>

</dd>
<dt id="Base_Unicode_Version()"><a class="permalink" href="./Unicode::Collate.html#Base_Unicode_Version()">#</a><a id="Base_Unicode_Version"></a><code>Base_Unicode_Version()</code></dt>
<dd>

<p>Returns the version number of UTS #10 this module consults, that should correspond with the DUCET incorporated.</p>

</dd>
</dl>

<h1 id="EXPORT"><a class="permalink" href="./Unicode::Collate.html#EXPORT">#</a>EXPORT</h1>

<p>No method will be exported.</p>

<h1 id="INSTALL"><a class="permalink" href="./Unicode::Collate.html#INSTALL">#</a>INSTALL</h1>

<p>Though this module can be used without any <code>table</code> file, to use this module easily, it is recommended to install a table file in the UCA format, by copying it under the directory &lt;a place in @INC&gt;/Unicode/Collate.</p>

<p>The most preferable one is &quot;The Default Unicode Collation Element Table&quot; (aka DUCET), available from the Unicode Consortium&#39;s website:</p>

<pre><code class="plaintext">http://www.unicode.org/Public/UCA/

http://www.unicode.org/Public/UCA/latest/allkeys.txt
(latest version)</code></pre>

<p>If DUCET is not installed, it is recommended to copy the file from http://www.unicode.org/Public/UCA/latest/allkeys.txt to &lt;a place in @INC&gt;/Unicode/Collate/allkeys.txt manually.</p>

<h1 id="CAVEATS"><a class="permalink" href="./Unicode::Collate.html#CAVEATS">#</a>CAVEATS</h1>

<dl>

<dt id="Normalization"><a class="permalink" href="./Unicode::Collate.html#Normalization">#</a>Normalization</dt>
<dd>

<p>Use of the <code>normalization</code> parameter requires the <b>Unicode::Normalize</b> module (see <a href="./Unicode::Normalize.html">Unicode::Normalize</a>).</p>

<p>If you need not it (say, in the case when you need not handle any combining characters), assign <code>(normalization =&gt; undef)</code> explicitly.</p>

<p>-- see 6.5 Avoiding Normalization, UTS #10.</p>

</dd>
<dt id="Conformance-Test"><a class="permalink" href="./Unicode::Collate.html#Conformance-Test">#</a><a id="Conformance"></a>Conformance Test</dt>
<dd>

<p>The Conformance Test for the UCA is available under <a href="http://www.unicode.org/Public/UCA/">http://www.unicode.org/Public/UCA/</a>.</p>

<p>For <i>CollationTest_SHIFTED.txt</i>, a collator via <code>Unicode::Collate-&gt;new( )</code> should be used; for <i>CollationTest_NON_IGNORABLE.txt</i>, a collator via <code>Unicode::Collate-&gt;new(variable =&gt; &quot;non-ignorable&quot;, level =&gt; 3)</code>.</p>

<p>If <code>UCA_Version</code> is 26 or later, the <code>identical</code> level is preferred; <code>Unicode::Collate-&gt;new(identical =&gt; 1)</code> and <code>Unicode::Collate-&gt;new(identical =&gt; 1,</code> <code>variable =&gt; &quot;non-ignorable&quot;, level =&gt; 3)</code> should be used.</p>

<p><b>Unicode::Normalize is required to try The Conformance Test.</b></p>

</dd>
</dl>

<h1 id="AUTHOR,-COPYRIGHT-AND-LICENSE"><a class="permalink" href="./Unicode::Collate.html#AUTHOR,-COPYRIGHT-AND-LICENSE">#</a><a id="AUTHOR"></a><a id="AUTHOR-COPYRIGHT-AND-LICENSE"></a>AUTHOR, COPYRIGHT AND LICENSE</h1>

<p>The Unicode::Collate module for perl was written by SADAHIRO Tomoyuki, &lt;SADAHIRO@cpan.org&gt;. This module is Copyright(C) 2001-2020, SADAHIRO Tomoyuki. Japan. All rights reserved.</p>

<p>This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>

<p>The file Unicode/Collate/allkeys.txt was copied verbatim from <a href="http://www.unicode.org/Public/UCA/13.0.0/allkeys.txt">http://www.unicode.org/Public/UCA/13.0.0/allkeys.txt</a>. For this file, Copyright (c) 2020 Unicode, Inc.; distributed under the Terms of Use in <a href="http://www.unicode.org/terms_of_use.html">http://www.unicode.org/terms_of_use.html</a></p>

<h1 id="SEE-ALSO"><a class="permalink" href="./Unicode::Collate.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<dl>

<dt id="Unicode-Collation-Algorithm-UTS-#10"><a class="permalink" href="./Unicode::Collate.html#Unicode-Collation-Algorithm-UTS-%2310">#</a><a id="Unicode"></a><a id="Unicode-Collation-Algorithm---UTS-10"></a>Unicode Collation Algorithm - UTS #10</dt>
<dd>

<p><a href="http://www.unicode.org/reports/tr10/">http://www.unicode.org/reports/tr10/</a></p>

</dd>
<dt id="The-Default-Unicode-Collation-Element-Table-(DUCET)"><a class="permalink" href="./Unicode::Collate.html#The-Default-Unicode-Collation-Element-Table-(DUCET)">#</a><a id="The"></a><a id="The-Default-Unicode-Collation-Element-Table-DUCET"></a>The Default Unicode Collation Element Table (DUCET)</dt>
<dd>

<p><a href="http://www.unicode.org/Public/UCA/latest/allkeys.txt">http://www.unicode.org/Public/UCA/latest/allkeys.txt</a></p>

</dd>
<dt id="The-conformance-test-for-the-UCA"><a class="permalink" href="./Unicode::Collate.html#The-conformance-test-for-the-UCA">#</a><a id="The1"></a>The conformance test for the UCA</dt>
<dd>

<p><a href="http://www.unicode.org/Public/UCA/latest/CollationTest.html">http://www.unicode.org/Public/UCA/latest/CollationTest.html</a></p>

<p><a href="http://www.unicode.org/Public/UCA/latest/CollationTest.zip">http://www.unicode.org/Public/UCA/latest/CollationTest.zip</a></p>

</dd>
<dt id="Hangul-Syllable-Type"><a class="permalink" href="./Unicode::Collate.html#Hangul-Syllable-Type">#</a><a id="Hangul"></a>Hangul Syllable Type</dt>
<dd>

<p><a href="http://www.unicode.org/Public/UNIDATA/HangulSyllableType.txt">http://www.unicode.org/Public/UNIDATA/HangulSyllableType.txt</a></p>

</dd>
<dt id="Unicode-Normalization-Forms-UAX-#15"><a class="permalink" href="./Unicode::Collate.html#Unicode-Normalization-Forms-UAX-%2315">#</a><a id="Unicode1"></a><a id="Unicode-Normalization-Forms---UAX-15"></a>Unicode Normalization Forms - UAX #15</dt>
<dd>

<p><a href="http://www.unicode.org/reports/tr15/">http://www.unicode.org/reports/tr15/</a></p>

</dd>
<dt id="Unicode-Locale-Data-Markup-Language-(LDML)-UTS-#35"><a class="permalink" href="./Unicode::Collate.html#Unicode-Locale-Data-Markup-Language-(LDML)-UTS-%2335">#</a><a id="Unicode2"></a><a id="Unicode-Locale-Data-Markup-Language-LDML---UTS-35"></a>Unicode Locale Data Markup Language (LDML) - UTS #35</dt>
<dd>

<p><a href="http://www.unicode.org/reports/tr35/">http://www.unicode.org/reports/tr35/</a></p>

</dd>
</dl>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
